package com.hunktimes.wholesale.ui.pages

import android.os.Bundle
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.hunktimes.wholesale.R
import com.hunktimes.wholesale.base.BasePageFragment
import com.hunktimes.wholesale.databinding.FragmentSearchBinding
import com.hunktimes.wholesale.widget.FlowLayoutManager

/**
 * Author: Delete
 * Date: 2020/7/27 11:43
 * Description:
 *
 */
class SearchFragment : BasePageFragment(R.layout.fragment_search) {
    lateinit var viewBinding: FragmentSearchBinding

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        viewBinding = FragmentSearchBinding.bind(view)
    }

    override fun onStart() {
        super.onStart()
        initHotTags()

        viewBinding.searchTv.setOnClickListener {
            rootNavController.navigate(R.id.action_navigation_search_to_navigation_search_result)
        }
    }

    val hotSearchTagAdapter = HotSearchTagAdapter()
    fun initHotTags() {
        val hotSearchTagLm = FlowLayoutManager()
        viewBinding.hotTagRcv.layoutManager = hotSearchTagLm
        viewBinding.hotTagRcv.adapter = hotSearchTagAdapter
        val data = mutableListOf<String>()
        data.add("产品A")
        data.add("产品A")
        data.add("产品A")
        data.add("产品aABCASDSADasdasd")
        hotSearchTagAdapter.data = data

    }

}

class HotSearchTagAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_hot_search_tag) {
    override fun convert(holder: BaseViewHolder, item: String) {
        holder.setText(R.id.item_hot_search_tag_tv, item)
    }
}